﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace GameJamKingdom
{
    public class SoundLibrary
    {
        public Dictionary<string, SoundEffectInstance> s;

        public SoundLibrary(Game1 cGame)
        {
            s = new Dictionary<string, SoundEffectInstance>();

            SoundEffect temp;
            temp = cGame.Content.Load<SoundEffect>("Sounds/BrickWallSmash");
            AddEffect("brickWall", temp);

            temp = cGame.Content.Load<SoundEffect>("Sounds/death02");
            AddEffect("death", temp);

            temp = cGame.Content.Load<SoundEffect>("Sounds/PowerUpAquire");
            AddEffect("powerup", temp);

            temp = cGame.Content.Load<SoundEffect>("Sounds/GoldScaleAcquire");
            AddEffect("goldScale", temp);

            temp = cGame.Content.Load<SoundEffect>("Sounds/spring");
            AddEffect("spring", temp);

            temp = cGame.Content.Load<SoundEffect>("Sounds/IceSlide");
            AddEffect("ice", temp);

            temp = cGame.Content.Load<SoundEffect>("Sounds/ClockSlowDown03");
            AddEffect("time", temp);

            //temp = cGame.Content.Load<SoundEffect>("SnakeRunnerLoop02");
            //AddEffect("musicLoop02", temp);

            temp = cGame.Content.Load<SoundEffect>("Sounds/Swim");
            AddEffect("swim", temp);
            //Song test; test.
            
        }

        public void AddEffect(string name, SoundEffect nEffect)
        {
            SoundEffectInstance test = nEffect.CreateInstance();
            s.Add(name, test);
        }

        public void play(string sound, float volume)
        {            
            s[sound].Volume = 0.05f;
            if (s[sound].State.Equals(SoundState.Stopped))
                s[sound].Play();


            //s[effect].Play(volume, 0.0f, 0.0f);
        }
    }
}
